package utilities;

import java.io.File;

/**
 * Sets and checks the default file-extensions for required 
 * in-game files. 
 * 
 * @author Guillermo Mendez-Kestler
 *
 */
public class FileFilter implements java.io.FileFilter {
	/**
	 * Default Extension. Set to {@value}, which is short for 
	 * <b>M</b>akuraryu <b>T</b>ower <b>D</b>efense.
	 */
	public static final String DEFAULT_EXTENSION = "MTD";
	
	/**
	 * Default Extension. Set to {@value}, which is short for 
	 * <b>M</b>akuraryu <b>T</b>ower Defense for 
	 * <b>T</b>owers.
	 */
	public static final String DEFAULT_EXT_TOWER = "MTT";
	
	/**
	 * Default Extension. Set to {@value}, which is short for 
	 * <b>M</b>akuraryu <b>T</b>ower Defense for 
	 * <b>E</b>nemies.
	 */
	public static final String DEFAULT_EXT_ENEMY = "MTE";
	
	/**
	 * Default Extension. Set to {@value}, which is short for 
	 * <b>M</b>akuraryu <b>T</b>ower Defense for 
	 * <b>P</b>rojectiles.
	 */
	public static final String DEFAULT_EXT_PROJECTILE = "MTP";
	
	/**
	 * What the extension will be set to. 
	 */
	private String EXT;

	/**
	 * Creates a file filter to check the default extension 
	 * on a file. The extension that is checked is set to 
	 * {@value #DEFAULT_EXTENSION}. 
	 * 
	 */
	public FileFilter() {
		EXT = DEFAULT_EXTENSION;
	}
	
	/**
	 * Creates a file filter to check the default extension 
	 * on a file. 
	 * 
	 * @param ext The file extension to inspect. 
	 */
	public FileFilter(String ext){
		EXT = ext;
	}

	/* (non-Javadoc)
	 * @see java.io.FileFilter#accept(java.io.File)
	 */
	public boolean accept(File pathname) {
		return pathname.getName().toUpperCase().endsWith(EXT);
	}

}
